package com.xcity.pomelo.response;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import com.xcity.game.activity.exchange.ItemExchangeTemplate;
import com.xcity.game.common.ItemResponse;
import com.xcity.game.item.ItemInfo;

import naga.x.net.impl.pomelo.PomeloMessage;
import naga.x.net.impl.pomelo.protocol.Message;

@PomeloMessage(type = Message.Type.RESPONSE)
public class ActivityItemExchangeInfoResponse extends Response {

	private int id; // 活动id
	private List<ActivityInfo> list = Collections.emptyList();
	
	public static class ActivityInfo {
		private ItemResponse item;
		private ItemResponse[] requires; // 需求物品
		public ActivityInfo(ItemExchangeTemplate template) {
			this.item = new ItemResponse(template.getItemId(), template.getItemCount());
			ItemInfo[] requires = template.getRequireItems();
			this.requires = new ItemResponse[requires.length];
			for (int i = 0; i < requires.length; i++) {
				this.requires[i] = new ItemResponse(requires[i]);
			}
		}
		public ItemResponse getItem() {
			return item;
		}
		public void setItem(ItemResponse item) {
			this.item = item;
		}
		public ItemResponse[] getRequires() {
			return requires;
		}
		public void setRequires(ItemResponse[] requires) {
			this.requires = requires;
		}
	}
	
	public ActivityItemExchangeInfoResponse(int serial, int activityId, List<ItemExchangeTemplate> templates) {
		super(serial);
		this.id = activityId;
		if (!templates.isEmpty()) {
			this.list = new ArrayList<ActivityInfo>(templates.size());
			for (int i = 0; i < templates.size(); i++) {
				this.list.add(new ActivityInfo(templates.get(i)));
			}
		}
	}

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public List<ActivityInfo> getList() {
		return list;
	}

	public void setList(List<ActivityInfo> list) {
		this.list = list;
	}
	
}
